﻿using System.Data;
using Koonsoft.HYCRM.Model;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace Koonsoft.HYCRM.DAL
{
    public class OrderTrackDAL
    {
        private Database database = DatabaseFactory.CreateDatabase("KOONCRMDB");

        /// <summary>
        /// 新增订单轨迹
        /// </summary>
        /// <param name="orderID"></param>
        /// <param name="empolyeeID"></param>
        /// <param name="orderStatus"></param>
        /// <param name="result"></param>
        /// <param name="remark"></param>
        public void AddTrack(string orderID,int empolyeeID,OrderStatus orderStatus,int result,string remark)
        {
            const string procedure = "Order_CreateOrderTrack";

            using (var cmd = database.GetStoredProcCommand(procedure))
            {
                database.AddInParameter(cmd, "@OrderID",DbType.String,orderID);
                database.AddInParameter(cmd, "@EmpolyeeID", DbType.Int32, empolyeeID);
                database.AddInParameter(cmd, "@ProcessType", DbType.Int32, (int)orderStatus);
                database.AddInParameter(cmd, "@Result", DbType.Int32, result);
                database.AddInParameter(cmd, "@Remark", DbType.String, remark);

                database.ExecuteNonQuery(cmd);
            }
        }
    }
}
